From 2406df9ada241a374d1182eef7bd385a77f551ea Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Fri, 25 Jul 2008 09:49:06 +0100 Subject: [PATCH] fs-backend: fix FD allocation for file creation The creation operation also opens a file, we need to allocate a virtual fd for that too. Signed-off-by: Samuel Thibault --- tools/fs-back/fs-ops.c | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/tools/fs-back/fs-ops.c b/tools/fs-back/fs-ops.c index 6315a4d975..f9f7d4a4ba 100644 --- a/tools/fs-back/fs-ops.c +++ b/tools/fs-back/fs-ops.c @@ -459,7 +459,17 @@ void dispatch_create(struct mount *mount, struct fsif_request *req) else { printf("Issuing create for file: %s\n", full_path); - ret = creat(full_path, mode); + ret = get_fd(mount); + if (ret >= 0) { + int real_fd = creat(full_path, mode); + if (real_fd < 0) + ret = -1; + else + { + mount->fds[ret] = real_fd; + printf("Got FD: %d for real %d\n", ret, real_fd); + } + } } printf("Got ret %d (errno=%d)\n", ret, errno); -- 2.30.2